#ifndef __OC_DocGenerate_H__
#define __OC_DocGenerate_H__

#include "ServerDef.h"
#include "OCMain/StringUtil.h"
#include "json/json.h"

namespace OCPP
{
	class _ServerExport OpenApiParameter
	{
	public:
		OpenApiParameter(
		String name,String desc,String in,String type,String example) {
			
			this->name = name;
			this->desc = desc;
			this->in = in;
			this->type = type;
			this->example = example;
		}
		String name, desc, in, type, example;
	};

	using OpenApiParameterList = std::vector<OpenApiParameter>;

	class _ServerExport OpenApiMethod
	{
	public:
		OpenApiMethod() {}

		OpenApiMethod& addParameter(
			String name, String desc, String in, String type, String example)
		{
			parameterList.push_back(OpenApiParameter(name, desc, in, type, example));
			return *this;
		}

		OpenApiMethod& setName(String value)
		{
			name = value;
			return *this;
		}

		OpenApiMethod& setPath(String value)
		{
			path = value;
			return *this;
		}

		OpenApiMethod& setDescription(String value)
		{
			description = value;
			return *this;
		}

		String name;
		String path;
		String description;
		OpenApiParameterList parameterList;
	};

	using OpenApiMethodList = std::vector<OpenApiMethod>;

	class _ServerExport OpenApiDoc
	{
	public:
		OpenApiDoc() {}
		OpenApiMethod& addMethod()
		{
			methodList.push_back(OpenApiMethod());
			return methodList[methodList.size() - 1];
		}

		void setBaseUrl(String value)
		{
			baseUrl = value;
		}

		String toString();
		String baseUrl;
		OpenApiMethodList methodList;
	};

	struct ApiDocMethodParam
	{
		bool isNotNull = false;
		String name;
		String desc;
		String sample;
	};

	struct ApiDocMehtod
	{
		String name;
		String sampleUrl;
		std::vector<ApiDocMethodParam> params;
	};

	using ApiDocMehtodVec = std::vector<ApiDocMehtod>;

	class _ServerExport DocGenerate
	{
	public:
		String toMarkdown(ApiDocMehtodVec apiVec, String path);
		String toOpenApi(ApiDocMehtodVec apiVec);
	};
}

#endif